<template>
  <div class="start" v-show="showStart">
    <div class="left">
      <div
          v-for="icon in iconList"
          :key="icon.id"
          @click.stop="menuClick(icon)"
          class="set-item"
        >
        <el-image :src="icon.imgUrl" style="width: 20px; height: 20px; padding: 13px" class="icon" />
      </div>

    </div>
    <div class="right">
      <div class="title">喜欢</div>
      <el-scrollbar height="100%">
        <div class="scroll-wrap">
          <div v-for="item in favoriteList" :key="item.id" class="item">
            <el-image :src="item.icon" style="width: 60px; height: 60px; margintop: 10px" />
            <div class="name">{{ item.name }}</div>
          </div>
        </div>
      </el-scrollbar>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref, reactive } from 'vue'

import { useOpenWin } from '@/hooks/use-open-win'
import { IIconInfo } from '@/components/desktop-icon'

import sfIcon from '@/assets/img/favorite/f2.png'
import documentImg from '@/assets/img/start-menu/document.png'
import systemImg from '@/assets/img/start-menu/system.png'
import userImg from '@/assets/img/start-menu/user.png'

const showStart = ref(false)

const iconList: IIconInfo[] = reactive([
  {
    id: 102,
    imgUrl: systemImg,
    name: '系统',
    path: '/home/win/setting'
  },
  {
    id: 100,
    imgUrl: documentImg,
    name: '菜单',
    path: '/home/win/menu'
  },
  {
    id: 101,
    imgUrl: userImg,
    name: '用户',
    path: '/home/win/user'
  }
])

const favoriteList = [
  { id: 1, icon: sfIcon, name: '系统' },
  { id: 2, icon: sfIcon, name: '系统' },
  { id: 3, icon: sfIcon, name: '系统' },
  { id: 4, icon: sfIcon, name: '系统' },
  { id: 5, icon: sfIcon, name: '系统' }
]
const menuClick = (icon: IIconInfo) => {
  useOpenWin(icon)
  showStart.value = !showStart.value
}
defineExpose({
  showStart
})
</script>

<style lang="less" scoped>
.start {
  width: 396px;
  height: 500px;
  position: absolute;
  bottom: 34px;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  z-index: 999;
  .left {
    width: 47px;
    height: 100%;
    display: flex;
    flex-direction: column-reverse;
    background-color: rgb(168, 168, 168, 0.9);
    border-left: 1px solid rgb(128, 128, 128);
    box-shadow: 1px 1px 10px 2px #ccc;

    .set-item {
      transition: all .4s ease-in-out;
    }
    .icon {
      &:hover {
        background: rgba(255, 255, 255, 0.7);
      }
    }
  }
  .right {
    flex: 1;
    padding: 20px;
    .title {
      font-size: 14px;
      height: 30px;
      line-height: 30px;
    }
    .scroll-wrap {
      display: flex;
      flex-wrap: wrap;
      .item {
        width: 100px;
        height: 100px;
        text-align: center;
        margin-right: 4px;
        margin-top: 4px;
        background: rgba(128, 128, 128, 0.4);
        &:nth-child(3n) {
          margin-right: 0;
        }
        .name {
          text-align: left;
          font-size: 12px;
          padding-left: 10px;
          line-height: 30px;
        }
      }
    }
  }
}
</style>
